import React, {Component} from "react";
import { withRouter } from 'react-router-dom';
import { Select, Form } from 'antd';

const { Option } = Select;

class ClasshourSelect extends Component{

    state = {
        data: []
    };

    render() {
        const { data } = this.state;
        return (
            <Form.Item name="orderNum">
                <Select placeholder="课时" showSearch allowClear>
                    {
                        data.map(item => <Option value={item.orderNum} key={item.id}>第{item.orderNum}课时</Option>)
                    }
                </Select>
            </Form.Item>
        )
    }

    componentDidMount() {
        this.axios({
            method: 'get',
            url: '/Classhour/getClasshourByCurriculumId',
            params: {
                CurriculumId: this.props.match.params.id,
                classCode: this.props.location.state.code
            }
        }).then(res => {
            if(res.success){
                this.setState({
                    data: res.data
                })
            }
        })
    }
}

export default  withRouter(ClasshourSelect)
